package com.bw.paper.mvp.view.user;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.blankj.utilcode.util.BarUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bw.paper.R;

import javax.inject.Inject;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class UserNameActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_name);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            //把状态栏标记为浅色，然后状态栏的字体颜色自动转换为深色
        }
        BarUtils.setStatusBarColor(this, Color.WHITE);
        //添加让出状态栏高度->防止contentView布局绘制到状态栏上
        BarUtils.addMarginTopEqualStatusBarHeight(findViewById(R.id.user_name_root));
        findViewById(R.id.user_nick_save_btn).setOnClickListener(this::onClick);
    }

    @Override
    public void onClick(View v) {
        EditText editText = findViewById(R.id.user_nick_edt);
        if (editText.getText()==null){
            ToastUtils.showShort("请输入昵称");
            return;
        }
        if (editText.getText().toString().isEmpty()){
            ToastUtils.showShort("请输入昵称");
            return;
        }
        Intent intent = new Intent();
        intent.putExtra("nick",editText.getText().toString());
        setResult(RESULT_OK,intent);
        finish();
    }
}
